package cn.yan.luowowo.util;

import cn.yan.luowowo.exception.LogicException;
import org.springframework.lang.Nullable;
import org.springframework.util.StringUtils;

/**
 * 参数判断工具类
 */
public class AssertUtil {
    /**
     * 判断指定的text是否为null
     * @param text
     * @param message
     */
    public static void hasLength(@Nullable String text, String message) {
        if (!StringUtils.hasLength(text)) {
            throw new LogicException(message);
        }
    }

    /**
     * 判断密码与确认密码是否一致
     * @param password
     * @param rpassword
     * @param message
     */
    public static void isEquest(String password, String rpassword,String message){
        if (password == null || rpassword == null){
            throw new RuntimeException("输入参数不能为空");
        }if(!password.equals(rpassword)){
            throw new LogicException(message);
        }
    }

}
